package com.itheima.controller;

import com.itheima.pojo.Dept;
import com.itheima.service.DeptService;
import com.itheima.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: zhengsuyang
 * @Desc:
 * @create: 2025-09-28 18:03
 **/
@RestController
@RequestMapping("/depts")
public class DeptController {
    @Autowired
    private DeptService deptService;

    /**
     * 根据id查询部门
     *
     * @param id
     * @return
     */
    @GetMapping
    public Dept getDeptById(@RequestParam Integer id) {
        return deptService.getById(id);
    }
    @GetMapping("/list")
    public List<Dept> list(){
        return deptService.list();
    }
}
